<template>
  <div class="bg_view">
    <div class="cam_item" v-for="item in depts" @click="goAppointment(item.id)">
      <div class="head">
        <div class="name">{{ item.deptName }}</div>
        <div class="btn" v-if="type == 'YYGH' ">预约挂号</div>
        <div class="btn" v-else-if="type == 'JRGH' ">挂今日号</div>
        <div class="btn" style="  width: 6.6875rem;" v-else-if="type == 'ZXWZ'">在线问诊预约</div>
      </div>
      <div class="line"></div>
      <div class="address">地址：{{ item.address }}</div>
    </div>
  </div>
</template>

<script>


import {getDeptInfo} from "@/api/api";


export default {
  data() {
    return {
      depts: [],
      isNight: "",
      isToday: "",
      type: this.$route.query.type
    };
  },
  created() {
    this.info = this.$route.query;
    this.isNight = this.info.isNight
    this.isToday = this.info.isToday
    this.getDeptInfo();
  },
  methods: {
    //跳转预约挂号or在线问诊
    goAppointment(parentId) {
      if (this.type == 'YYGH') {
        this.$router.push({
          path: "/appointment?parentId=" + parentId + "&isNight=" + this.isNight + "&isToday="
        });
      } else if (this.type == 'JRGH') {
        this.$router.push({
          path: "/appointment?parentId=" + parentId + "&isNight=" + this.isNight + "&isToday=1"
        });
      } else if (this.type == 'ZXWZ') {
        //在线问诊
        this.$router.push({
          path: "/appointment?parentId=" + parentId + "&isOnline=1"
        });
      } else if (this.type == 'KSJS') {

        this.$router.push({
          path: "/department_introduced?parentId=" + parentId
        });
      }
    },
    getDeptInfo() {
      getDeptInfo({
        deptId: "",
        parentId: "0",
        level: "0",
        isNight: this.isNight,
        isToday: this.isToday
      }).then((res) => {
        this.depts = res.data;
      });
    },
  }
};
</script>
<style scoped>
.bg_view {
  height: 100%;
  min-height: 100vh;
  background-color: #f4f8fc;
}

.cam_item {
  background: #ffffff;
  box-shadow: 0px 0px 11px 0px rgba(173, 195, 228, 0.43);
  border-radius: 6px;
  margin: 1rem;
  margin: 0.75rem auto;
  width: calc(100% - 3.75rem);
  padding: 0 0.875rem;
}

.cam_item .head {
  height: 2.9375rem;
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.cam_item .head .name {
  font-size: 16px;
  font-family: PingFang SC;
  font-weight: 500;
  color: #131A2A;
}

.cam_item .head .btn {
  width: 4.6875rem;
  height: 1.75rem;
  background: linear-gradient(0deg, #448eff 0%, #66a3ff 100%);
  border-radius: 3px;
  text-align: center;
  line-height: 1.75rem;
  font-size: 15px;
  font-family: PingFang SC;
  font-weight: 500;
  color: #FFFFFF;
  line-height: 24px;
}

.cam_item .line {
  width: calc(100%);
  height: 0.0625rem;
  background-color: #e7ecf5;
}

.cam_item .address {
  font-size: 14px;
  font-family: PingFang SC;
  font-weight: 500;
  color: #a4adbe;
  line-height: 20px;
  padding: 0.75rem 0;
}
</style>
